from django.contrib import admin
from file_manage import models
# Register your models here.
# admin.site.register(models.User)

# class role_choice(admin.StackedInline):
#
#     model = models.Role
#     extra = 1
#
#
# class User_admin(admin.ModelAdmin):
#     """
#     admin格式显示
#     """
#     fieldsets = [
#         ("必填字段",{'fields':['name',"password"]}),
#         # ("Time", {'fields':,'classes': ['collapse']}),
#         ("sss",{'fields':['user_role']}),
#     ]#class样式隐藏
#     inlines = [role_choice]



class User_admin(admin.StackedInline):
    """
    admin格式显示
    """
    fieldsets = [
        ("必填字段",{'fields':['name',"password"]}),
        # ("Time", {'fields':,'classes': ['collapse']}),
        # ("sss",{'fields':['email_address']}),
    ]#class样式隐藏
    model = models.User
    extra = 1

class role_choice(admin.ModelAdmin):
    fieldsets = [
        ("必填字段", {'fields': ['position']}),
        # ("Time", {'fields':,'classes': ['collapse']}),
        # ("sss", {'fields': ['user_role']}),
    ]  # class样式隐藏
    inlines = [User_admin,]

class User_list(admin.ModelAdmin):
    fieldsets = [
        ("必填字段",{'fields':['name',"password"]}),
        # ("Time", {'fields':,'classes': ['collapse']}),
        ("非必填项",{'fields':['user_role','email_condition'],'classes':['collapse']}),
        ("邮箱选择",{'fields':['email_data',],'classes':['filter_horizontal','collapse',]})
    ]#class样式隐藏
    #！！多对多非常重要的显示方式
    filter_horizontal = ('email_data',)

# class group_Inline(admin.StackedInline):
#     model=models.


# class (admin.ModelAdmin):
class Email_list(admin.ModelAdmin):
    fieldsets = [
        ("邮箱地址添加", {'fields': ['email_address', ]}),
        # ("邮箱组选择", {'fields':['Email_group_set']}),
    ]  # class样式隐藏

    # inlines = [group_Inline,]


class Email_group_list(admin.ModelAdmin):
    fieldsets = [
        ("必填字段",{'fields':['name']}),
        ("邮箱组选择邮箱",{'fields':['email_data']}),
    ]
    filter_vertical = ('email_data',)


# class Compile_list_inline(admin.StackedInline):
#     model = models.Compile

class App_list(admin.ModelAdmin):
    fieldsets = [
        ("必填字段",{'fields':['name',"app_english_name",'short_name','app_path','app_compile_num','app_script']}),
    ]




class Compile_list(admin.ModelAdmin):
    fieldsets = [
        ("必填字段",{'fields':['compile_script_path']})
    ]

admin.site.register(models.Role,role_choice)
admin.site.register(models.User,User_list)
admin.site.register(models.Email,Email_list)
admin.site.register(models.Email_group,Email_group_list)
admin.site.register(models.App,App_list)
admin.site.register(models.Compile,Compile_list)